<?php
namespace app\api\controller;

/**
 * 上传控制器
 * Class Upload
 * @package app\admin\controller
 *
 */
class Upload extends \app\api\ApiBase
{
    public function file()
    {
        $file = request()->file('file');
        $data = request()->post();
        $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads' . DS . 'files');
        if($info){
            $key = '/public' . DS . 'uploads' . DS . 'files' . DS . $info->getSaveName();
            $key = str_replace('\\','/',$key);
            return $this->returnSuccess([
                "name" => $key,
                "url"  => request()->domain().$key,
            ]);
        }
        return $this->returnFail($file->getError());
    }
} //Class End


